<cpanel include="../../config.php">

<?

/***************************************************************************
 *                                 subdomains_manage.php
 *                            -------------------
 *   Begin                : Thursday, April 16, 2005
 *   Copyright            : (C) 2005 Point and Code
 *   Domain               : http://www.pointandcode.com/
 *   Email                : support@pointandcode.com
 *   Version              : 1.0.0
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

$html_root_path = '../../';
include $root_path.'common.php';
$page_title = $lang['subdomains'];
include $root_path.'page_header.php';

$current_subdomains_with_junk = <<<EOFpacman
<cpanel SubDomain="cplistsubdomains()">
EOFpacman;

$array_of_subdomains_with_junk = array();
$array_of_subdomains_with_junk = explode('<br>', $current_subdomains_with_junk);

$i = 0;
foreach ($array_of_subdomains_with_junk as $row) {

	$temp = explode(' (', $row);
	$array_of_current_subdomains[$i]['subdomain'] = $temp['0'];

	$array_of_subdomain_bits = array();
	$array_of_subdomain_bits = explode('.', $temp['0']);
	$count_of_subdomain_bits = count($array_of_subdomain_bits);
	$reconstructed_subdomain = $array_of_subdomain_bits['0']."_";
	
	for ($j = 1; $j<$count_of_subdomain_bits; $j++) {
		if ($j!=1) {
			$reconstructed_subdomain .=	".";
		};
		$reconstructed_subdomain .= $array_of_subdomain_bits[$j];
	};
	$array_of_current_subdomains[$i]['subdomain_bit'] = $reconstructed_subdomain;
	$array_of_current_subdomains[$i]['folder'] = str_replace(")", "", $temp['1']);

	$i++;
};
$i = 0;
foreach ($array_of_current_subdomains as $row) {

	if (!empty($row['folder'])) {
		$template->assign_block_vars('current_subdomains_row', array(
			'ROWCLASS' => ($i%2) ? $template_cfg['class_row_1'] : $template_cfg['class_row_2'],
			'SUBDOMAIN' => $row['subdomain'],
			'FOLDER' => $row['folder'],
			'U_DELETE' => 'subdomains_delete_done.php?domain='.$row['subdomain_bit'],
			'U_SETUP_REDIRECT' => 'subdomains_setup_redirect.php?domain='.$row['subdomain_bit'],
			'U_DELETE_REDIRECT' => 'subdomains_delete_redirect_done.php?domain='.$row['subdomain_bit'],
		));
	$i++;
	};
};

// Don't ask me why this is an email domain... That seems odd. But the function's straight out of X's subdomain page...
$s_domains = <<<EOFpacman
<cpanel Email="listmaildomainsopt()">
EOFpacman;

$template->assign_vars(array(
	'S_DOMAINS' => $s_domains,
	'U_ADD_ACTION' => "subdomains_add_done.php",
	
	'L_SUBDOMAINS' => $lang['subdomains'],
	'L_SUBDOMAINS_INTRO_1' => $lang['subdomains_intro_1'],
	'L_SUBDOMAINS_INTRO_2' => $lang['subdomains_intro_2'],
	'L_SUBDOMAIN' => $lang['subdomain'],
	'L_FOLDER' => $lang['folder'],
	'L_ACTIONS' => $lang['actions'],
	'L_SETUP_REDIRECT' => $lang['setup_redirect'],
	'L_DELETE_REDIRECT' => $lang['delete_redirect'],
	'L_DELETE' => $lang['delete'],
	'L_CREATE_SUBDOMAIN' => $lang['create_subdomain'],
	'L_FTP' => $lang['ftp'],
	'L_FTP_MESSAGE' => $lang['subdomain_ftp_message'],
	'L_DNS' => $lang['dns'],
	'L_DNS_MESSAGE' => $lang['subdomain_dns_message'],
	)
);

$template->set_filenames(array(
	'body' => $root_path.$template_path.'domains/subdomains_manage.tpl')
);

//
// Woohoo! All done!
//
$template->pparse('body');




include $root_path.'page_tail.php';




?>